package com.example.cyclops;

import java.util.ArrayList;

import com.example.cyclops.DataUtils.PlayerControl;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;

public class LoadingActivity extends Activity{

	public static ArrayList<PDFOutlineElement> mPdfOutlinesCount = new ArrayList<PDFOutlineElement>();
	public static ArrayList<PDFOutlineElement> mPdfOutlines = new ArrayList<PDFOutlineElement>();
	String UserID;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);	
		mPdfOutlinesCount = new ArrayList<PDFOutlineElement>();
		mPdfOutlines = new ArrayList<PDFOutlineElement>();
		setContentView(R.layout.loading);
        Bundle bundle = this.getIntent().getExtras();
		UserID = bundle.getString("userid");
			
	new Handler().postDelayed(new Runnable(){
		@Override
		public void run(){
			DataUtils datautils = new DataUtils(Global.remoteip,Global.remoteport);
			ArrayList<PlayerControl> control = datautils.List(UserID);
			int IndexLevel = 0;
				
			PDFOutlineElement pdfOutlineElement = 
						new PDFOutlineElement(
								"0","正在直播",false, true, "top", 
								IndexLevel,false,null,null,null,null);
			mPdfOutlinesCount.add(pdfOutlineElement);
				
			for(PlayerControl t:control){
				PDFOutlineElement pdfOutlineElement2 = 
						new PDFOutlineElement("0",t.getName(), true, false, 
								"0", ++IndexLevel,false,t.getUrl(),"1935",UserID,"0");
					mPdfOutlines.add(pdfOutlineElement2);	
			}
			Intent intent = new Intent();
			Bundle bundle = new Bundle();
			intent.putExtras(bundle);
			intent.setClass(LoadingActivity.this, MythListView.class);
			startActivity(intent);
			finish();
		}
	}, 200);
   }
}